<?php
namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Hash;
use function Matrix\add;    //引入hash

class IpLimitRepository
{
    /**
     * 新增数据
     * @param  $param
     * @return bool
     * @throws BasicException
     */
    public function  add($param){
       app('model_ip_limit')->insert($param);
    }

    /**
     * 白名单列表
     * @param  $page
     * @param  $perPage
     * @return mix
     */
    public  function  white_list($page,$perPage){
       $list = app('model_ip_limit')->with('user_data:user_id,user_code,nickname,head_picture')
       ->where('type',2)
       ->select('id','user_id','add_time')
       ->paginate($perPage, ['*'], '', $page);
       return $list;
    }


    /**
     * 删除白名单
     * @param  $user_id
     * @throws BasicException
     */
    public   function  del_user_white($user_id){
        app('model_ip_limit')->where('user_id',$user_id)->where('type',2)->delete();
    }

    /**
     * 删除地域黑名单
     * @throws BasicException
     */
    public   function  del_regions(){
        app('model_ip_limit')->where('type',1)->delete();
    }


    /**
     * 删除限制登录地域黑名单
     * @throws BasicException
     */
    public   function  login_del_regions(){
        app('model_ip_limit')->where('type',3)->delete();
    }




}


?>